package com.cn.wanxi.message;

import com.cn.wanxi.message.utils.ParamNameUtil;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.EnableScheduling;

@SpringBootApplication
@EnableScheduling //开启定时任务
public class MessageApplication {


    public static void main(String[] args) {
        ConfigurableApplicationContext app = SpringApplication.run(MessageApplication.class, args);

        //获取容器中的RedisTemplate
        RedisTemplate redisTemplate = (RedisTemplate) app.getBean("redisTemplate");


        //添加几个用户
        for (int i = 0; i < ParamNameUtil.USERNAME_ALL.length; i++) {
            redisTemplate.opsForValue().set(ParamNameUtil.REDIS_REGISTERED_USER_NAME +
                    ParamNameUtil.USERNAME_ALL[i], ParamNameUtil.PASSWORD_ALL);
        }


    }

}
